package com.cy.gameserver.service;

import com.cy.gameserver.dao.entity.GPSSign;
import com.cy.gameserver.dao.mapper.GPSSignMapper;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by tiankai.qin on 18/4/9.
 */
@Service
public class GPSSignService {

    private static final Logger logger = LoggerFactory.getLogger(GPSSignService.class);


    @Autowired
    private GPSSignMapper gpsSignMapper;


    /**
     * 通过xy坐标以及半径r，找到留言
     *
     * @param x
     * @param y
     * @param r
     * @return
     */
    public List<GPSSign> getGPSSign(float x, float y, float r) {
        List<GPSSign> gpsSigns = gpsSignMapper.selectGPSSignByXY(x + r, x - r, y + r, y - r);

        List<GPSSign> examp = Lists.newArrayList();
        GPSSign gpsSign = new GPSSign();
        gpsSign.setGid(1233);
        gpsSign.setCompass(0);
        gpsSign.setX(39.87183f);
        gpsSign.setY(116.4797f);
        gpsSign.setVertical(0);
        gpsSign.setHorizontal(0);
        gpsSign.setContent("到此一游啦啦啦啦啦啦");
        examp.add(gpsSign);

        GPSSign gpsSign2 = new GPSSign();
        gpsSign2.setGid(1235);
        gpsSign2.setCompass(0);
        gpsSign2.setX(55.8232f);
        gpsSign2.setY(110.32442f);
        gpsSign2.setVertical(0);
        gpsSign2.setHorizontal(0);
        gpsSign2.setContent("请勿乱涂乱画");
        examp.add(gpsSign2);

        return gpsSigns;
    }


    public void saveGPSSign(GPSSign gpsSign) {
        gpsSignMapper.insertGPSSign(gpsSign);
    }
}
